<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
$(document).ready(function() {
	$("#listTbody").on("click","input[name=responseSeller]",function(){
		var id=$(this).next().next().val();
		var sellerName=$(this).next().next().next().val();
		var sellerAddress=$(this).next().next().next().next().val();
		var sellerInfo=$(this).next().next().next().next().next().val();
		$.ajax({
			type:"post",
			url:"responseSeller.do",
			data:"id="+id+"&sellerName="+sellerName+"&sellerAddress="+sellerAddress+"&sellerInfo="+sellerInfo,
			dataType:"json",
			success:function(jsonData){ 
				alert("판매자승인완료");
				$("#listTbody tr").remove();
				var str="";
				$.each(jsonData,function(index,value) {
				str+="<tr><td>"+value.askNo+"</td><td>"+value.id;
				str+="</td><td>"+value.totalPoint+"</td><td>"+value.sellerName;
				str+="</td><td>"+value.sellerAddress+"</td><td>"+value.sellerInfo;
				str+="</td><td><textarea rows=3>"+value.mess+"</textarea></td>";
				str+="<td><center><input type=button name=responseSeller value=승인>";
				str+="<input type=button name=cancle value=취소>";
				str+="<input type=hidden name=id value="+value.id+">";	
				str+="<input type=hidden name=sellerName value="+value.sellerName+">";
				str+="<input type=hidden name=sellerAddress value="+value.sellerAddress+">";
				str+="<input type=hidden name=sellerInfo value="+sellerInfo+">";
				str+="</center></td></tr>";
				}); 
				$("#listTbody").append(str);
			}
		});
	});//click 
	
	$("#listTbody").on("click","input[name=cancle]",function(){
		var id=$(this).next().val();
		$.ajax({
			type:"post",
			url:"responseSellerCancle.do",
			data:"id="+id,
			dataType:"json",
			success:function(jsonData){ 
				alert("판매자신청취소확인");
				$("#listTbody tr").remove();
				var str="";
				$.each(jsonData,function(index,value) {
				str+="<tr><td>"+value.askNo+"</td><td>"+value.id;
				str+="</td><td>"+value.totalPoint+"</td><td>"+value.sellerName;
				str+="</td><td>"+value.sellerAddress+"</td><td>"+value.sellerInfo;
				str+="</td><td><textarea rows=3>"+value.mess+"</textarea></td>";
				str+="<td><center><input type=button name=responseSeller value=승인>";
				str+="<input type=button name=cancle value=취소>";
				str+="<input type=hidden name=id value="+value.id+">";	
				str+="<input type=hidden name=sellerName value="+value.sellerName+">";
				str+="<input type=hidden name=sellerAddress value="+value.sellerAddress+">";
				str+="<input type=hidden name=sellerInfo value="+sellerInfo+">";
				str+="</center></td></tr>";
				}); 
				$("#listTbody").append(str);
			}
		});
	});//click 
});//ready
</script>
</head>
<body>
<h2>판매자 신청현황</h2>
<form id="responseSellerForm">
<table border="1" cellpadding="5">
<thead>
<tr>
	<th>NO</th><th>신청자 ID</th><th>신청자 총포인트</th>
	<th>판매명</th><th>판매지</th><th>판매 정보</th>
	<th>신청메세지</th><th>판매자 등록승인</th>
</tr>
</thead>
<tbody id="listTbody">
<c:forEach items="${requestScope.list }" var="li">
<tr>
	<td>${li.askNo }</td><td>${li.id }</td><td>${li.totalPoint }</td>
	<td>${li.sellerName }</td><td>${li.sellerAddress }</td><td>${li.sellerInfo }</td>
	<td><textarea rows="3" >${li.mess}</textarea></td>
	<td><center><input type="button" name="responseSeller" value="승인">
	<input type="button" name="cancle" value="취소">
	<input type="hidden" name="id" value="${li.id}">
	<input type="hidden" name="sellerName" value="${li.sellerName}">
	<input type="hidden" name="sellerAddress" value="${li.sellerAddress}">
	<input type="hidden" name="sellerInfo" value="${li.sellerInfo}">
	</center>
	</td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
</body>
</html>